package com.xh.bussiness.teachbook.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.xh.bussiness.teachbook.bean.dto.TeachingBookModuleDetailDto;
import com.xh.bussiness.teachbook.bean.dto.TeachingBookModuleDto;
import com.xh.bussiness.teachbook.bean.request.QueryTeachingBookModuleDetailRequest;
import com.xh.bussiness.teachbook.dao.TeachingBookModuleDetailMapper;
import com.xh.bussiness.teachbook.model.TeachingBookModule;
import com.xh.bussiness.teachbook.model.TeachingBookModuleDetail;
import com.xh.bussiness.teachbook.service.ITeachingBookModuleDetailService;
import com.xh.core.service.impl.BaseServiceImpl;
import com.xh.core.util.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/*
 * @Author daiwei
 * @Description
 * @Date 2019/5/13 14:47
 **/
@Service
public class TeachingBookModuleDetailServiceImpl
        extends BaseServiceImpl<TeachingBookModuleDetailMapper,TeachingBookModuleDetail>
        implements ITeachingBookModuleDetailService {

    @Autowired
    private TeachingBookModuleDetailMapper mapper;

    @Override
    public List<TeachingBookModuleDetail> queryTeachingBookModuleDetailListByParentId(String teachingBookId, String teachingBookModuleId) {
        QueryWrapper<TeachingBookModuleDetail> qw=new QueryWrapper<>();
        qw.eq("teaching_book_id",teachingBookId);
        if(!StringUtils.isEmpty(teachingBookModuleId)){
            qw.eq("teaching_book_module_id",teachingBookModuleId);
        }
        qw.orderByAsc("order_no");
        List<TeachingBookModuleDetail> details= this.selectList(qw, TeachingBookModuleDetail.class);
        return details;
    }

    @Override
    public List<TeachingBookModuleDetail> queryTeachingBookModuleDetailByParams(QueryTeachingBookModuleDetailRequest request) {
        return mapper.queryByParams(request);
    }

}
